﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using DataModel;

namespace StockManagement
{
    /// <summary>
    /// AddMaterialStockWindow.xaml 的交互逻辑
    /// </summary>
    public partial class AddMaterialStockWindow : Window
    {
        public StockRecordItem stockRecItem { get; set; }

        public AddMaterialStockWindow()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                stockRecItem = new StockRecordItem()
                {
                    MaterialName = nameTB.Text,
                    Reason = reasonTB.Text,
                    RecTime = DateTime.Now,
                    StockDir = (putinRadioBtn.IsChecked == true ? StockDirection.PutIn : StockDirection.TakeOut),
                    Value = Convert.ToDouble(changeValueTB.Text)
                };
                this.DialogResult = true;
                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("请输入正确的数值");
            }
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }
    }
}
